package com.gitee.wsl.compose.chart.xy.bar.bullet.indicator

import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.graphics.Shape
import com.gitee.wsl.compose.chart.ExperimentalKoalaPlotApi

/**
 * A default implementation of a bar indicator that can be used for the featured measure or qualitative ranges.
 * @param fraction The fraction of the overall bullet graph background height the indicator will occupy.
 * @param brush The brush to paint the bar with
 * @param shape An optional shape for the bar.
 * @param border An optional border for the bar.
 */
@ExperimentalKoalaPlotApi
@Composable
 fun HorizontalBarIndicator(
    brush: Brush,
    modifier: Modifier = Modifier,
    fraction: Float = 1f,
    shape: Shape = RectangleShape,
    border: BorderStroke? = null
) {
    Box(
        modifier = modifier.fillMaxWidth().fillMaxHeight(fraction)
            .then(if (border != null) Modifier.border(border, shape) else Modifier)
            .background(brush = brush, shape = shape)
            .clip(shape)
    )
}